/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andre
 */
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "funcionario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Funcionario.findAll", query = "SELECT f FROM Funcionario f"),
    @NamedQuery(name = "Funcionario.findByDataAdmissao", query = "SELECT f FROM Funcionario f WHERE f.dataAdmissao = :dataAdmissao"),
    @NamedQuery(name = "Funcionario.findBySalario", query = "SELECT f FROM Funcionario f WHERE f.salario = :salario"),
    @NamedQuery(name = "Funcionario.findByDataDemissao", query = "SELECT f FROM Funcionario f WHERE f.dataDemissao = :dataDemissao")})
public class Funcionario extends Pessoa implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataAdmissao", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataAdmissao;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "salario", nullable = false)
    private double salario;
    
    @Column(name = "dataDemissao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataDemissao;
    
    @ManyToMany(mappedBy = "funcionarioList")
    private List<Folha> folhaList;
    
    @JoinColumn(name = "idFuncao", referencedColumnName = "idFuncao", nullable = false)
    @ManyToOne(optional = false)
    private Funcao funcao;

    public Funcionario() {
    }
    
    public Funcionario(Integer idPessoa){
        super(idPessoa);
    }

    public Funcionario(Integer idPessoa, String nome, int cgc, int rg, Date dataNascimento, String twitter, String facebook, Date dataAdmissao, Double salario) {
        super(idPessoa, nome, cgc, rg, dataNascimento, twitter, facebook);
        this.dataAdmissao = dataAdmissao;
        this.salario = salario;
    }

    public Date getDataAdmissao() {
        return dataAdmissao;
    }

    public void setDataAdmissao(Date dataAdmissao) {
        this.dataAdmissao = dataAdmissao;
    }

    public double getSalario() {
        return salario;
    }

    public void setSalario(double salario) {
        this.salario = salario;
    }

    public Date getDataDemissao() {
        return dataDemissao;
    }

    public void setDataDemissao(Date dataDemissao) {
        this.dataDemissao = dataDemissao;
    }

    @XmlTransient
    public List<Folha> getFolhaList() {
        return folhaList;
    }

    public void setFolhaList(List<Folha> folhaList) {
        this.folhaList = folhaList;
    }

    public Funcao getFuncao() {
        return funcao;
    }

    public void setFuncao(Funcao funcao) {
        this.funcao = funcao;
    }
    
}
